import ModalAction from 'lib/Modal/Action';


export default class InfoEdit extends ModalAction {
    onOk = () => {
        const formData = this.models.infoFormM.get('formData');
        const [currentEditIndex] = this.models.daPageM.get(['currentEditIndex']);
        const listData = this.models.listM.get('data');

        if (typeof currentEditIndex === 'number') {
            listData[currentEditIndex] = formData;
        } else {
            listData.push(formData);
        }

        this.models.listM.set({
            data: [...listData]
        });
        this.close();
    }
}